//
//  FXCycleScrollView.h
//  FanXing
//
//  Created by Wilson on 16/4/5.
//  Copyright © 2016年 kugou. All rights reserved.
//  三方控件
//
#import <UIKit/UIKit.h>

@class FXCycleScrollView;

enum {
    FXCycleScrollViewDirectionHorizontal =   0,
    FXCycleScrollViewDirectionVertical   =   1,
};typedef NSUInteger FXCycleScrollViewDirection;

enum {
    FXCycleScrollViewTransitionAuto      =   0,
    FXCycleScrollViewTransitionForward   =   1,
    FXCycleScrollViewTransitionBackward  =   2
}; typedef NSUInteger FXCycleScrollViewTransition;

@protocol FXCycleScrollViewDelegate <NSObject>
@optional
- (void)lazyScrollViewWillBeginDragging:(FXCycleScrollView *)pagingView;
//Called when it scrolls, except from as the result of self-driven animation.
- (void)lazyScrollViewDidScroll:(FXCycleScrollView *)pagingView at:(CGPoint) visibleOffset;
//Called whenever it scrolls: through user manipulation, setup, or self-driven animation.
- (void)lazyScrollViewDidScroll:(FXCycleScrollView *)pagingView at:(CGPoint) visibleOffset withSelfDrivenAnimation:(BOOL)selfDrivenAnimation;
- (void)lazyScrollViewDidEndDragging:(FXCycleScrollView *)pagingView;
- (void)lazyScrollViewWillBeginDecelerating:(FXCycleScrollView *)pagingView;
- (void)lazyScrollViewDidEndDecelerating:(FXCycleScrollView *)pagingView atPageIndex:(NSInteger)pageIndex;
- (void)lazyScrollView:(FXCycleScrollView *)pagingView currentPageChanged:(NSInteger)currentPageIndex;
@end

typedef UIView*(^FXCycleScrollViewDataSource)(NSUInteger index);

@interface FXCycleScrollView : UIScrollView

@property (copy)                FXCycleScrollViewDataSource      dataSource;
@property (nonatomic, weak)   id<FXCycleScrollViewDelegate>    controlDelegate;

@property (nonatomic,assign)    NSUInteger                      numberOfPages;
@property (readonly)            NSUInteger                      currentPage;
@property (readonly)            FXCycleScrollViewDirection       direction;

@property (nonatomic, assign) BOOL autoPlay;
@property (nonatomic, assign) CGFloat autoPlayTime; //default 3 seconds
//是否添加点击手势
@property (nonatomic, assign) BOOL addTapGesture;
/**
 当点击的时候，执行的block
 **/
@property (nonatomic, copy) void(^TapActionBlock)(NSInteger pageIndex);

- (id)initWithFrameAndDirection:(CGRect)frame
                      direction:(FXCycleScrollViewDirection)direction
                 circularScroll:(BOOL) circularScrolling;

- (void)setEnableCircularScroll:(BOOL)circularScrolling;
- (BOOL)circularScrollEnabled;

- (void) reloadData;

- (void) setPage:(NSInteger) index animated:(BOOL) animated;
- (void) setPage:(NSInteger) newIndex transition:(FXCycleScrollViewTransition) transition animated:(BOOL) animated;
- (void) moveByPages:(NSInteger) offset animated:(BOOL) animated;

- (UIView *) visibleViewController;

- (void)autoPlayHanlde:(id)timer;
- (void)autoPlayPause;
- (void)autoPlayResume;
@end